<!-- #include file="configuracoes.asp" -->
<!-- #include file="interface/head.asp" -->
<%

tabela = requestGET("tabela")
tabela2 = requestGET("tabela2")
opcao = requestGET("opcao")

permissao tabela &"_"& tabela2

id = requestGET("id")
valor = requestGET("valor")


	AbreConexaoAux tabela


DIM i, j

Select Case opcao

	Case "deletar"
		
			str = "DELETE from "&tabela2&" where id="&id
  			Set rsD = conexao_aux.Execute(str)		
			
			
			Response.Write("Registro Deletado")

	Case "adicionar"
		
			str = "INSERT INTO "&tabela2&" ("

			str2 = "Describe "&tabela2
			Set rsTabela = conexao_aux.Execute(str2)	
			If not rsTabela.eof then rsTabela.MoveNext
			cont=0
			Do while not rsTabela.eof
				If cont>0 then str=str&","
				str=str&" "&rsTabela("Field")
			cont=cont+1
			rsTabela.MoveNext
			Loop
			
			str=str&") VALUES ("
			
			str2 = "Describe "&tabela2
			Set rsTabela = conexao_aux.Execute(str2)	
			If not rsTabela.eof then rsTabela.MoveNext			
			cont=0
			
			DIM branco, campo
			branco = true
			
			Do while not rsTabela.eof
				If cont>0 then str=str&","
				campo = requestFORM(rsTabela("Field"))
				str=str&" '"&campo&"'"
				if left(rsTabela("Type"),3)="int" AND campo ="" then branco = false
			cont=cont+1
			rsTabela.MoveNext
			Loop
			str=str&")"
			
			If branco=true then	Set rsI = conexao_aux.Execute(str)
			
			response.Redirect "banco.asp?tabela="&tabela&"&tabela2="&tabela2
				
					
	Case "editar"
	
		tam = len(id)
	
		sepa = split(id,"_")
			
		campo = right(id, tam - len(sepa(0))-1)
		
		id = sepa(0)
		
		condicao = "id="&id	
		
		If valor<>"" then
		
			sql_edicao conexao_aux, tabela2, campo, valor, condicao
	
		End IF
		
			Response.Write("&nbsp;"&valor)		

End Select


%>

<!-- #include file="interface/footer.asp" -->